#include <X11/Xutil.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <glib/gi18n.h>
#include <stdio.h>
#include <libtiffanygirl/libtiffanygirl.h>
#include "systray_menu.h"
#include "tiffanygirl.h"

TiffanyGirl *tiffgirl;

static gint systray_menupopup(GtkWidget *widget, TiffanyGirl *tiffgirl)
{
	gtk_menu_popup(tiffgirl->systray_menu->menu, NULL, NULL, NULL, NULL, NULL, NULL);
	return TRUE;
}

int main(gint argc, gchar** argv)
{
	TGirl *tgirl;

	/* Initializing */
	gtk_init(&argc, &argv);

#ifdef ENABLE_NLS
	bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR );
	bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" );
	textdomain ( GETTEXT_PACKAGE );
#endif

	tiffgirl = g_new0(TiffanyGirl, 1);
	tiffgirl->windowlist = NULL;

	/* system tray */
	tiffgirl->systray = gtk_status_icon_new();
	gtk_status_icon_set_from_icon_name(tiffgirl->systray, "tomboy");
	gtk_status_icon_set_tooltip(tiffgirl->systray, _("Tiffanygirl Note"));
	gtk_status_icon_set_visible(tiffgirl->systray, TRUE);

	tiffgirl->tgirl = tiffanygirl_new();
	tiffanygirl_scanning(tiffgirl->tgirl);

	/* Menu */
	tiffgirl->systray_menu = systray_menu_new(tiffgirl->tgirl->note_list);
	g_signal_connect(tiffgirl->systray, "activate", G_CALLBACK(systray_menupopup), tiffgirl);

	/* Create Window */
/*	suseosd->window = gtk_window_new(GTK_WINDOW_POPUP);
	gtk_window_set_urgency_hint(GTK_WINDOW(suseosd->window), FALSE);
	gtk_window_set_decorated(GTK_WINDOW(suseosd->window), FALSE);
	gtk_window_set_skip_pager_hint(suseosd->window, TRUE);
	gtk_window_set_skip_taskbar_hint(suseosd->window, TRUE);
	gtk_widget_realize(suseosd->window);
	gdk_window_set_keep_below(GTK_WIDGET(suseosd->window)->window, TRUE);
	gtk_window_set_position(suseosd->window, GTK_WIN_POS_CENTER);
	gdk_window_set_accept_focus(GTK_WIDGET(suseosd->window)->window, FALSE);
	gtk_window_stick(suseosd->window);
*/
	//g_signal_connect(suseosd->window, "delete-event", G_CALLBACK(window_delete), NULL);

	/* Loading image file */
/*	suseosd->image = gtk_image_new_from_file(image_path);

	if (message) {
		suseosd->message_box = gtk_label_new(message);

		suseosd->box = gtk_vbox_new(FALSE, 0);
		gtk_box_pack_start(GTK_BOX(suseosd->box), GTK_WIDGET(suseosd->image), FALSE, FALSE, 0);
		gtk_box_pack_start(GTK_BOX(suseosd->box), GTK_WIDGET(suseosd->message_box), FALSE, FALSE, 0);
		gtk_container_add(GTK_CONTAINER(suseosd->window), suseosd->box);
	} else {
		gtk_container_add(GTK_CONTAINER(suseosd->window), suseosd->image);
	}

	gtk_widget_show_all(GTK_WIDGET(suseosd->window));
*/
	//sleep(period);
	gtk_main();

	return 0;
}
